package com.md.config.client;

import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.lang.NonNull;

import java.io.IOException;

/**
 * @author 刘骄阳
 * 2023-10-12 14:23
 */
public class PreRequestInterceptor implements ClientHttpRequestInterceptor {
  /**
   * 拦截请求,执行指定操作
   * 前置拦截
   *
   * @param request   the request, containing method, URI, and headers
   * @param body      the body of the request
   * @param execution the request execution
   * @return the response
   * @throws IOException in case of I/O errors
   */
  @NonNull
  @Override
  public ClientHttpResponse intercept(@NonNull final HttpRequest request, @NonNull final byte[] body,
                                      final ClientHttpRequestExecution execution) throws IOException {
    return execution.execute(request, body);
  }
}
